var express = require('express');
var router = express.Router();
var hget = require('../util/httpget');
var hpost = require('../util/httppost');
const querystring = require("querystring");
let util = require('util');

/* GET home page. */
router.get('/', function(req, res, next) {
   hget("http://localhost:9000/abc/cccc")
   .then(function(data){
  res.render("Home",{data:data})
 });
});

router.get('/pi', function(req, res, next) {
  res.render('person_information', { title: '个人中心' });
});

router.get('/lo', function(req, res, next) {
  res.render('login_view', { title: '登录' });
});

router.post('/lo', function(req, res, next) {
  res.render('login_view', { title: '登录' });
});

router.get('/re', function(req, res, next) {
  res.render('registe_view', { title: '注册' });
});

router.get('/home', function(req, res, next) {
  hget("http://localhost:9000/abc/cccc")
   .then(function(data){
   res.render('PerHome',{data:data})
 });
  
});
router.post('/hpo', function(req, res, next) {

  console.log(req.body.name);
  var i =1;
 //res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'}); 
  hget("http://localhost:9000/abc/cccc?"+querystring.stringify({name:req.body.name}))
   .then(function(data){
  res.render("PerHome",{data:data})
 });
});

router.post('/po', function(req, res, next) {

  console.log(req.body.name);
  var i =1;
 //res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'}); 
  hget("http://localhost:9000/abc/cccc?"+querystring.stringify({name:req.body.name}))
   .then(function(data){
  res.render("Home",{data:data})
 });
});

module.exports = router;
